<template>
  <div class="dashboard-editor-container">
    <h1>数据总览</h1>

    <panel-group :panelGroupData="panelGroupData"/>

    <el-row :gutter="32">
      <el-col :span="12">
        <div class="chart-wrapper">
          <bar-chart :lineChartData="lineChartData"/>
        </div>
      </el-col>
      <el-col :span="12">
        <div class="chart-wrapper">
           <line-chart :reservationData="reservationData" />
        </div>
      </el-col>
    </el-row>

    <el-row :gutter="32">
      <el-col :span="12">
       <registrationList></registrationList>
      </el-col>
      <el-col :span="12">
        <el-row :gutter="32">
          <el-col :span="12"><departmentList></departmentList></el-col>
           <el-col :span="12"><doctorsList></doctorsList></el-col>
        </el-row>
      </el-col>
    </el-row>


  </div>
</template>

<script>
import PanelGroup from './components/PanelGroup'
import LineChart from './components/LineChart'
import BarChart from './components/BarChart'
import registrationList from './components/registrationList'
import departmentList from './components/departmentList'
import doctorsList from './components/doctorsList'

import {getHomeListData} from '@/api/homeData'

// const lineChartData = {
//   newVisitis: {
//     expectedData: [100, 120, 161, 134, 105, 160, 165]
//   }
// }

export default {
  name: 'DashboardAdmin',
  components: {
    PanelGroup,
    LineChart,
    BarChart,
    registrationList,
    departmentList,
    doctorsList
  },
  data() {
    return {
      panelGroupData:{
        registerTotal:0,
        spendTotal:0,
        rechargeTotal:0
      },
      lineChartData:[],
      reservationData:[]
    }
  },
  mounted() {
    this.getHomeListData();
  },
  methods: {
     //获取首页数据
     getHomeListData(){
       let that = this;
       getHomeListData().then(res=>{
         if(res.code == 2000){
            let data = res['data'];
            that.panelGroupData.registerTotal = data['registerTotal'];
            that.panelGroupData.spendTotal = data['spendTotal'];
            that.panelGroupData.rechargeTotal = data['rechargeTotal'];
            that.lineChartData = data['reservationData'];
            that.reservationData = data['rechargeData'];
         } else {
             that.$message.warning("请选择对应的权限")
         }

       });
     }
  },


}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .github-corner {
    position: absolute;
    top: 0px;
    border: 0;
    right: 0;
  }

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

@media (max-width:1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
</style>
